package edu.whut.test;

import java.util.Scanner;

/*
* 模拟用户登录，一共三次机会
* */
public class StringTest01 {
    public static void main(String[] args) {
        String username = "admin";
        String password = "123456";
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i <3 ; i++) {
            System.out.println("请输入用户名：");
            String inputUserName = sc.nextLine();
            System.out.println("请输入密码：");
            String inputPassWord = sc.nextLine();
            if(username.equals(inputUserName) && password.equals(inputPassWord)){
                System.out.println("登录成功！");
                break;
            }else{
                if(i==2){
                    System.out.println("明天再来吧！");
                }else {
                    System.out.println("登陆失败！你还有" + (2 - i) + "次机会！");
                }
            }
        }
    }
}
